package com.newenergy.wisehome.common.helper;

import android.text.TextUtils;
import android.util.Log;

/**
 * Created by kyx on 2018/7/5.
 */

public class StorageHelper {

    public  static void  setLanguage(String language){
        String key = "asr_language";
        SPUtil.put(key,language);
    }
    public  static String  getLanguage(){
        String key = "asr_language";
       return SPUtil.getString(key,"cmn-Hans-CN");
    }

    public static void setBLAccountInfo(String[] accounts) {
        String key = "bl_account";
        if (accounts == null || accounts.length != 2) {
             Log.e("LFX", "不保存账号信息");
            SPUtil.put(key, "");
            return;
        }
        String accountInfo = accounts[0] + "-" + accounts[1];
        SPUtil.put(key, accountInfo);
    }

    public static String[] getBLAccountInfo() {
        String key = "bl_account";
        String accountInfo = SPUtil.getString(key, null);
        if (TextUtils.isEmpty(accountInfo) || !accountInfo.contains("-")) {
            return null;
        }
        String[] infos = accountInfo.split("-");
        return infos;
    }


    public static void setWifiSSID(String ssid) {
        String key = "WIFI_SSID";
        SPUtil.put(key, ssid);
    }

    public static String getWifiSSID() {
        String key = "WIFI_SSID";
        return SPUtil.getString(key, null);
    }

    public static void setWifiPwd(String pwd) {
        String key = "WIFI_PWD";
        SPUtil.put(key, pwd);
    }

    public static String getWifiPwd() {
        String key = "WIFI_PWD";
        return SPUtil.getString(key, null);
    }

    public static String getCurrFamilyId() {
        return SPUtil.getString("FAMILY_ID","12345678");
    }
}
